import re
import os
import encodeingcheck
#TxMax=500
try:
   os.remove('db_new.txt')
except FileNotFoundError:
    pass
TxMax=input("set txpower maximum")
dbEncode=encodeingcheck.encodeingcheck("db.txt")
f = open("db.txt",encoding=dbEncode)
lines = f.readlines()
a= open('db_new.txt', 'a',encoding=dbEncode)
for line in lines:
    x = line.split(", (", 1)
    try:
        x2 = x[1]
        x2 = re.sub(r'[\d]+', TxMax, x2)
        x1=x[0]
        line=x1+", ("+x2
    except IndexError:
        pass
    a.write(line)
a.close()
f.close()
os.remove("db.txt")
os.rename("db_new.txt","db.txt")
